<template>
	<view>
		<view class="" style="margin-top: 20px;">
			<scroll-view scroll-x class="bg-white nav text-center fixed" style="margin-top: 50px;">
				<view class="cu-item" :class="index==TabCur?'text-blue cur':''" v-for="(item,index) in tabNav"
					:key="index" @tap="tabSelect" :data-id="index">
					{{tabNav[index]}}
				</view>
			</scroll-view>
			<block v-if="TabCur==0">
				<navigator v-for="(item, index) in jinhuoList" :key="index" :url="'/pages/goods/detail/detail?goods_id=' + item.goods_id">
					<view class="myfirst" style="display: flex; margin-bottom: 10px;">
						<view class="mypic">
							<image 
							:src="item.pic_cover_small == '' ? $util.img('upload/uniapp/default_goods.png') : $util.img(item.pic_cover_small)" 
							mode="aspectFit"></image>
						</view>
						<view class="mycontent" style="">
							<text class="mydesc">{{ item.goods_name }}</text>
							<view class="myoperation">
								<text class="" style="color: #FF0036 !important;">¥{{ item.promotion_price }}</text>
								<!-- <text class="" style="color: #898989 !important;">销量：{{ item.sales }}</text> -->
							</view>
						</view>
						<view class="">
							<uniNumberBox></uniNumberBox>
						</view>
					</view>
					
				</navigator>
				
				<!-- 购物车 -->
				<!-- <view class="number-wrap">
					<view class="number-line">
						<text class="title">购买数量</text>
						<text class="limit-txt" v-if="goodsDetail['max_buy'] > 0">
							(每人限购{{ goodsDetail['max_buy'] }}
							<template v-if="goodsDetail.goods_unit != ''">
								{{ goodsDetail.goods_unit }}
							</template>
							<template v-else>
								件
							</template>
							)
						</text>
						<view class="number">
							<button type="default" class="decrease" @click="changeNum('-')">-</button>
							<input class="uni-input" type="number" v-model="number" placeholder="0" @input="keyInput" />
							<button type="default" class="increase" @click="changeNum('+')">+</button>
						</view>
					</view>
				</view> -->
				<!-- 购物车 -->
				<view class="" v-for="(item,index) in goodsDetail">
					<text>{{item}}</text>
				</view>

			</block>
			<block v-if="TabCur==1">
				<view class="myfirst">
					<navigator v-for="(item, index) in weiList" :key="index" :url="'/pages/goods/detail/detail?goods_id=' + item.goods_id">
						<view class="myfirst" style="display: flex; margin-bottom: 10px;">
							<view class="mypic">
								<image 
								:src="item.pic_cover_small == '' ? $util.img('upload/uniapp/default_goods.png') : $util.img(item.pic_cover_small)" 
								mode="aspectFit"></image>
							</view>
							<view class="mycontent" style="">
								<text class="mydesc">{{ item.goods_name }}</text>
								<view class="myoperation">
									<text class="" style="color: #FF0036 !important;">¥{{ item.promotion_price }}</text>
									<!-- <text class="" style="color: #898989 !important;">销量：{{ item.sales }}</text> -->
								</view>
							</view>
						</view>
					</navigator>
					

				</view>
			</block>
		</view>
	</view>
</template>
<style lang="scss">
@import 'static/css/goods/detail.scss';
</style>
<script>
	import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue';
	import http from 'common/js/http.js';
	import orderAction from '../public/js/orderAction.js';
	// import detail from '../../../static/js/goods/detail.js;
	import detail from '../../../static/js/goods/detail.js'
	export default {
		components: {
			uniNumberBox,
		},
		mixins: [http, detail],
		mixins: [http, orderAction],
		data() {
			return {
				CustomBar: this.CustomBar,
				TabCur: 0,
				tabNav: ['已购买', '未购买'],
				jinhuoList: '',
				weiList:'',
				goodsDetail:''
			};
		},
		async onShow() {
			this.getjinhuoList();
			// this.getWeipay();
			await this.getGoodsDetail();
		},
		methods: {
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
			},
			// 获取进货单的商品
			getjinhuoList() {
				var that = this;
				this.sendRequest({
					url: 'System.Order.orderGoods',
					data: {},
					success: res => {
						console.log('System.Order.orderGoods  res===============', res)
						this.jinhuoList = res.data.good
						this.weiList = res.data.goods
						console.log('this.jinhuoList===============', this.jinhuoList)
						console.log('weiList===============', this.weiList)
						// console.log('this.jinhuoList.code===============', this.jinhuoList.data.data)
					}
				});
			},
			getGoodsDetail(){
				this.sendRequest({
					url: 'System.Goods.goodsDetail',
					data: {},
					success: res => {
						console.log('System.Order.goodsDetail  res===============', res)
					}
				});
				// System.Goods.goodsDetail
			}
		},
		
	}
</script>

<style lang="scss">
	@import '../../goods/public/css/category.scss';
	@import '../../../static/css/main.css';
	@import '../public/css/list.scss';
	.mycontent{
		flex: 1; margin-left: 10px;display: flex;flex-direction: column;
		justify-content: space-around;
	}
	.myoperation{
		display: flex;
		justify-content: space-between;
	}
	.mypic{
		margin-right: 10px;
	}

	.mypic image {
		// margin-right: 10px;
		width: 66px;
		height: 66px;
	}

	.myfirst {
		background-color: #FFFFFF;
		width: 700rpx;
		margin: 0 auto;
		padding: 20rpx;
	}

	page {
		background-color: #f8f8f8;
		padding-top: 45px;
	}
</style>
